package file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

import org.apache.commons.lang.StringUtils;

public class FileTest {
	public static void main(String[] args) throws IOException {
//		String dc  = Charset.defaultCharset().name();
//		FileInputStream in = new FileInputStream("C:/Users/sunniwell/Desktop/Group_Export_Template.txt");
//        UnicodeInputStream uin = new UnicodeInputStream(in,dc);
//		BufferedReader reader = new BufferedReader(new InputStreamReader(uin));
//		String line = null;
//		while((line=reader.readLine()) != null){
//			if(StringUtils.isNotBlank(line) && !line.startsWith("#")){
//				System.out.println(line);
//			}
//		}
//		reader.close();
		
		deleteDir(new File("C:\\Users\\admin\\Desktop\\aa"));
	}
	
	/**
     * 递归删除目录下的所有文件及子目录下所有文件
     * @param dir 将要删除的文件目录
     * @return boolean Returns "true" if all deletions were successful.
     *                 If a deletion fails, the method stops attempting to
     *                 delete and returns "false".
     */
    private static boolean deleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i=0; i<children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }
        // 目录此时为空，可以删除
        return dir.delete();
    }
    
}
